import { Component, Injector, ViewChild, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { AppConsts } from '@shared/AppConsts';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { AppComponentBase } from '@shared/common/app-component-base';
import { HttpClient } from '@angular/common/http';
import { DataItemServiceProxy, WorkflowServiceProxy } from '@shared/service-proxies/service-proxies';
import { ChoseUserComponent } from '../FlowConfig/ChoseUser/ChoseUser.component';
import { FileDownloadService } from '@shared/utils/file-download.service';
import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent';
import { Paginator } from 'primeng/components/paginator/paginator';
import { Table } from 'primeng/components/table/table';
import { DataItemDetailCreateComponent } from '../BaseDataItem/DataItemDetailCreate/DataItemDetailCreate.component';
import { DataItemCreateComponent } from '../BaseDataItemType/DataItemCreate/DataItemCreate.component';
import { finalize } from 'rxjs/operators';
import { from } from 'rxjs';
import * as _ from 'lodash';
import { TreeNode, MenuItem } from 'primeng/api';

@Component({
  selector: 'FlowConfig',
  templateUrl: './FlowConfig.component.html',
  styleUrls: ['./FlowConfig.component.css']
})
export class FlowConfigComponent extends AppComponentBase {
  @ViewChild('ChoseUser') ChoseUser: ChoseUserComponent;

  itemAyy = []; 
  selectedOu: TreeNode;
  filterText = '';
  itemName: string;

  constructor(injector: Injector,
    private _dataItemAppServiceProxy: DataItemServiceProxy,
    private _workflowServiceProxy: WorkflowServiceProxy,
    private _activatedRoute: ActivatedRoute,
    private _httpClient: HttpClient) {
    super(injector);
    this.getDataItemTree();
  }
  getDataItemTree(): void {
    this._dataItemAppServiceProxy.getDataItemDetailByItemTypeName('流程类型').subscribe(resultdata => {
      console.log(resultdata)
      this.itemAyy = resultdata;
    });
  }
  nodeSelect(event) {
    this.itemName = event.node.label;
    this._workflowServiceProxy.getStepByWorkFlowName(this.itemName).subscribe(dto => {
      console.log(dto)
      this.primengTableHelper.totalRecordsCount = dto.length;
      this.primengTableHelper.records = dto;
      this.primengTableHelper.hideLoadingIndicator();
    });
  }
  changePage() {
    console.log('111111')
    this._workflowServiceProxy.getStepByWorkFlowName(this.itemName).subscribe(dto => {
      console.log(dto)
      this.primengTableHelper.totalRecordsCount = dto.length;
      this.primengTableHelper.records = dto;
      this.primengTableHelper.hideLoadingIndicator();
    });
  }
}
